{# Stalker Pyramid a Web Base Production Asset Management System
 Copyright (C) 2009-2014 Erkan Ozgur Yilmaz

 This file is part of Stalker Pyramid.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation;
 version 2.1 of the License.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#}
{% extends 'base.jinja2' %}

{# PRE-HEADER #}
{% block pre_header %}

    <link rel="stylesheet"
          href='{{ request.static_url("stalker_pyramid:static/ace/css/chosen.min.css") }}'/>
    <link rel="stylesheet"
          href='{{ request.static_url("stalker_pyramid:static/ace/css/datepicker.css") }}'/>
    <link rel="stylesheet"
          href='{{ request.static_url("stalker_pyramid:static/ace/css/bootstrap-timepicker.css") }}'/>
    <link rel="stylesheet"
          href='{{ request.static_url("stalker_pyramid:static/ace/css/daterangepicker.css") }}'/>
    <link rel="stylesheet"
          href='{{ request.static_url("stalker_pyramid:static/ace/css/colorpicker.css") }}'/>
    <link rel="stylesheet"
          href='{{ request.static_url("stalker_pyramid:static/ace/css/jquery-ui-1.10.3.custom.min.css") }}'/>
{#    <link rel="stylesheet"#}
{#          href='{{ request.static_url("stalker_pyramid:static/ace/css/bootstrap-editable.css") }}'/>#}

{% endblock pre_header %}

{# SIDEBAR #}
{% block sidebar %}

    {% if entity %}
        {% include 'sidebar.jinja2' %}
    {% endif %}

{% endblock sidebar %}

{# BREADCRUMBS #}
{% block breadcrumbs %}

    {% set page_title='Update' %}
    {% include 'breadcrumb/breadcrumbs.jinja2' %}

{% endblock breadcrumbs %}

{# PAGE-CONTENT #}
{% block page_content %}

    {% set department=entity %}
    {% set page_title='Update' %}
    {% include 'page_header.jinja2' %}

    <div class="row-fluid">
        <div class="widget-box span6">
            <div class="widget-header widget-header-small header-color-grey">
                <h4 class="smaller">
                    <i class="icon-info-sign"></i>
                </h4>

            </div>

            <div class="widget-body">
                <div class="widget-main">
                    <div class="row-fluid">
                        <div class="span3">
                            {% include 'components/avatar.jinja2' %}
                        </div>
                        <div class="span9">

                            {% set mode='Update' %}
                            {% include 'department/dialog/department_basic_information_form.jinja2' %}
                        </div>
                    </div>
                </div>

                <div class="row-fluid">
                    <div class="form-actions">

                        <button id='submit_button' type="button"
                                class='btn btn-success pull-right'>
                            <i class="icon-edit"></i> Update
                        </button>
                    </div>

                </div>
            </div>
        </div>
    </div>



{% endblock page_content %}

{# EXTRA-SCRIPTS #}
{% block extrascripts %}

    <script src='{{ request.static_url("stalker_pyramid:static/ace/js/jquery.validate.min.js") }}'></script>
    <script src='{{ request.static_url("stalker_pyramid:static/ace/js/jquery.gritter.min.js") }}'></script>

    <script src='{{ request.static_url("stalker_pyramid:static/ace/js/jquery.ui.touch-punch.min.js") }}'></script>
{#    <script src='{{ request.static_url("stalker_pyramid:static/ace/js/x-editable/bootstrap-editable.min.js") }}'></script>#}
{#    <script src='{{ request.static_url("stalker_pyramid:static/ace/js/x-editable/ace-editable.min.js") }}'></script>#}


    <script type="text/javascript">


        $(document).ready(function () {


            var submit_button = $('#submit_button');
            submit_button.on('click', function (e) {

                e.stopPropagation();
                e.preventDefault();
                submit_button.button('loading');

                var department_update_form = $("#department_form");
                $.post('/departments/{{ entity.id}}/update', department_update_form.serialize()
                        ).done(function (response_text) {
                            bootbox.alert(response_text);
                            window.location.assign('{{ came_from }}');
                            submit_button.button('reset');
                        }).fail(function (jqXHR) {
                            bootbox.alert(jqXHR.responseText);
                            submit_button.button('reset');
                        });

            });
        });


    </script>

{% endblock extrascripts %}
